﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using AnYeCun.Entity.ShareCode;
using AnYeCun.Business.ShareCode;

namespace AnYeCun.Web.Mvc.Admin.Controllers
{
    public class ShareCodeClassController : Controller
    {
        //
        // GET: /ShareCodeClass/

        public ActionResult Index(int? pageIndex, int? pageSize)
        {
            pageIndex = pageIndex ?? 1;
            pageSize = pageSize ?? 20;
            var list = new List<ShareCodeClassEntity>();
            return View(list);
        }

        public ActionResult Add()
        {
            return View();
        }

        [HttpPost]
        public ActionResult Add(ShareCodeClassEntity shareCodeClass)
        {

            if (string.IsNullOrEmpty(shareCodeClass.Name))
            {
                ModelState.AddModelError("", "Edit Failure, see inner exception");
            }
            else
            {
                if (ShareCodeManager.SaveShareCodeClass(shareCodeClass))
                {
                    ModelState.AddModelError("", "保存成功");
                }
                else
                {
                    ModelState.AddModelError("", "保存失败");
                }
            }
            return View();
        }

        public ActionResult Edit(long classId)
        {
            return View();
        }

        [HttpPost]
        public ActionResult Edit(ShareCodeClassEntity shareCodeClass)
        {
            return View();
        }

    }
}
